<html>
	<head>
		<title>preview camera</title>
		<script type="text/javascript" language="javascript">
			function clickConnect() {
				oPreview0.MediaType = 1;
				oPreview0.ID = 1;
				oPreview0.MediaSource = 'eto.iobb.net';
				oPreview0.MulticastIP = '228.5.6.1';
				oPreview0.MediaChannel = 1;
				oPreview0.StreamID = 1;
				oPreview0.MediaUsername = 'admin';
				oPreview0.MediaPassword = '123456';
				oPreview0.Httpport = '8005';
				oPreview0.RegisterPort = '6000';
				oPreview0.ControlPort = '6005';
				oPreview0.StreamingPort = '60005';
				oPreview0.MulticastPort = '5100';
				oPreview0.RecordType= "1";
				oPreview0.Connect(0);
                                
				setTimeout(function(){alert('stoprecord');
                                    oPreview0.StopRecordEx();
                                }, (1000 * 60));
			}
			
			//
			function clickDisConnect(){
				oPreview0.FreeAudioToken();
			}
			
			//
			function StartRec(){alert('record');
				try {
					if ( oPreview0.RecordType == "0" ) {
						oPreview0.StartRecordEx('c:\\RecTest\\');
					} else if ( oPreview0.RecordType == "1" ) {
						oPreview0.StartRecordEx('c:\\RecTest\\');
					}
				} catch(e) {
                                    alert('error');
					debug(e);
				}
			}
			
			// 
			function onStop(){
				oPreview0.StopRecordEx();
			}
			
			//
			function OnStartRecord (nID, successful, szFileName) {
				try {
					console.log( szFileName ) ;
				} catch(e) {
					debug(e)
					alert(e.description)
				}
			}
			//
			function OnStopRecord(nID, szFileName) {
				try {
					console.log(  szFileName ) ;
				} catch(e) {
					debug(e)
				}
			}
                        function OnConnect(nID, successful) {
				try {
					if (successful){alert('play');
                                            oPreview0.Play();
                                            setTimeout(function(){
                                                StartRec();
                                            }, 3000);
					}
				} catch(e) {
					debug(e);
				}
			}
			window.onload = function () {
                            clickConnect();
                        }
		</script>
	</head>
	<body>
		
		<OBJECT id="oPreview0" height="240" width="352" data="data:application/x-oleobject;base64,P2/zpuA6i0WvxKqCVl4L+BAHAABhJAAAzhgAAA==" classid="CLSID:F8E691A0-C92E-4E42-9CDA-62FC07A9483B" VIEWASTEXT></OBJECT>
                <script for="oPreview0" event="OnConnect(nID, successful)">OnConnect(nID, successful);</script>
		<script for="oPreview0" event="OnStartRecord(nID,successful, szFileName)">OnStartRecord(nID,successful, szFileName);</script>
		<script for="oPreview0" event="OnStopRecord(nID, szFileName)">OnStopRecord(nID, szFileName);</script>
	</body>
</html>